package com.API.beans;

import com.API.dal.entities.Objects;
import com.API.dal.providers.OrdersProvider;
import com.API.dal.entities.Orders;
import org.primefaces.context.RequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Scope("request")
public class OrdersBean {

    @Autowired
    OrdersProvider ordersProvider;

    Objects customer = new Objects();
    Orders order;
    List<Orders> ordersList;

    public List<Orders> getOrdersList() {
        if (ordersList == null) {
            ordersList = ordersProvider.getOrders();
        }
        return ordersList;
    }

    public Orders getOrder() {
        return order;
    }

    public Objects getCustomer() {
        return customer;
    }

    public void setOrder(Orders order) {
        this.order = order;
    }

    public void setCustomer(Objects customer) {
        this.customer = customer;
    }

    public void addOrder() {
        final RequestContext context = RequestContext.getCurrentInstance();
        context.execute("addDialog.show()");
    }

    public void editOrder() {

    }

    public void deleteOrder() {

    }
}
